<?php

namespace App\Handles;

use GuzzleHttp\Client;

class KimVpnHandler
{
    const SERVICE_INFO_URL = 'getLiveServiceInfo';

    protected $client;

    protected $appId;

    protected $appKey;

    public function __construct()
    {
        $this->client = new Client(['base_uri' => 'https://api.64clouds.com/v1/', 'timeout' => 5.0]);
        $this->appId = env('VPN_API_ID');
        $this->appKey = env('VPN_API_KEY');
    }

    public function Info()
    {
        $response = $this->client->get(self::SERVICE_INFO_URL,['query'=>[
            'veid' => $this->appId,
            'api_key' => $this->appKey
        ]]);
        $info = json_decode($response->getBody(), true);
        if (empty($info)) {
            return [];
        }
        return $info;
    }

}